﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;

//using Microsoft.VisualStudio.TestTools.UnitTesting;

//using Pibby.Core.Common;

//namespace Pibby.Core.Ioc.Tests
//{
//    [TestClass]
//    public class TypeFactoryTests
//    {
//        class StandaloneTypeClass
//        {
//            public readonly string id = Guid.NewGuid().ToString();
//        }

//        interface IFooInterface
//        {
//            string ID
//            {
//                get;
//            }
//        }

//        abstract class AbstractClassImplementingIFooInterface : IFooInterface
//        {
//            public abstract string ID { get; }
//        }

//        class ConcreteClassImplementingIFooInterface : AbstractClassImplementingIFooInterface
//        {
//            private readonly string id = Guid.NewGuid().ToString();

//            public override string ID
//            {
//                get { return id; }
//            }

//        }

//        class ConcreteClassWithNoDefaultConstructor : AbstractClassImplementingIFooInterface
//        {
//            private readonly string id = Guid.NewGuid().ToString();

//            public override string ID
//            {
//                get { return id; }
//            }

//            public ConcreteClassWithNoDefaultConstructor(string text)
//            {
//            }
//        }

//        private TypeFactory _factory;

//        [TestInitialize]
//        public void Setup()
//        {
//            this._factory = new TypeFactory(new SimpleTypeResolver());
//        }

//        [TestMethod]
//        [ExpectedException(typeof(ContractFailureException))]
//        public void TypeFactory_InitialisingWithNull_ThrowsException()
//        {
//            var factory = new TypeFactory(null);

//            factory.CreateTypeOf<string> ();

//            Assert.Fail("Expecting an exception from the null argument to constructor");
//        }

//        [TestMethod]
//        public void TypeFactory_CanCreate_NewInstanceOfType()
//        {
//            this._factory.RegisterType<IFooInterface, ConcreteClassImplementingIFooInterface>();

//            IFooInterface newInstance = this._factory.CreateTypeOf<IFooInterface>();

//            Assert.IsTrue(newInstance is ConcreteClassImplementingIFooInterface, "Created object is not of the correct type");
//        }

//        [TestMethod]
//        [ExpectedException(typeof(TypeNotRegisteredException))]
//        public void TypeFactory_CreatingNewInstanceOfType_NoDefaultConstructor_ThrowsException()
//        {
//            this._factory.RegisterType<IFooInterface, ConcreteClassWithNoDefaultConstructor>();

//            IFooInterface newInstance = this._factory.CreateTypeOf<IFooInterface>();

//            Assert.Fail("Expecting exception because of missing default constructor");
//        }

//        //[TestMethod]
//        //[Explicit]
//        //public void TypeFactory_CannotRegisterUnrelatedTypes_BecauseOfCompilerError()
//        //{
//        //    Assert.Ignore("Ignore this test - uncomment next line to prove compile time error");
//        //    // InversionOfController.RegisterType<IFooInterface, StandaloneTypeClass>();

//        //    IFooInterface newInstance = InversionOfController.CreateTypeOf<IFooInterface>();

//        //    Assert.IsTrue(newInstance is ConcreteClassImplementingIFooInterface, "Created object is not of the correct type");
//        //}

//        [TestMethod]
//        [ExpectedException(typeof(System.ArgumentException))]
//        public void TypeFactory_CannotRegisterAbstractType_ForInstantiation()
//        {
//            this._factory.RegisterType<IFooInterface, AbstractClassImplementingIFooInterface>();

//            Assert.Fail("Expecting an exception for abstract class");
//        }

//        interface INotImplementedByAnyConcreteTypes
//        {
//            string Foo { get; }
//        }

//        [TestMethod]
//        [ExpectedException(typeof(TypeNotRegisteredException))]
//        public void TypeFactory_AskingForTypeNotRegistered_ThrowsException()
//        {
//            this._factory.CreateTypeOf<INotImplementedByAnyConcreteTypes>();

//            Assert.Fail("Expecting exception for not registered type");
//        }
//    }
//}

